<?php
/**
 * Custom
 * 
 * LICENSE:
 * 
 * @category   Custom
 * @package    Custom
 * @subpackage Controller
 * @copyright  Copyright (c)  KenJi
 * @license    
 * @version    
 */

/**
 * Zend_Controller_Plugin_Abstract
 */
require_once	'Zend/Controller/Plugin/Abstract.php';

class	Custom_Controller_Plugin_KenAuth	extends	Zend_Controller_Plugin_Abstract 
{
	/**
	 * An instance of Zend_Auth
	 * @var Zend_Auth
	 */
	private $_auth;
	
	/**
	 * An instance of Custom_Acl
	 * @var Custom_Acl
	 */
	private $_acl;
	
	/**
	 * Redirect to a new controller when the user has a invalid indentity.
	 * @var array
	 */
	private $_noauth=array(	'module'=>'default',
							'controller'=>'auth',
							'action'=>'login');
	/**
	 * Redirect to 'error' controller when the user has a vailid identity 
	 * but no privileges
	 * @var array
	 */
	private $_nopriv=array(	'module'=>'default',
							'controller'=>'error',
							'action'=>'privileges');
	
	/**
	 * Constructor.
	 * @return void
	 */
	
	public function	__construct($auth,$acl)
	{
		$this->_auth=$auth;
		$this->_acl=$acl;
	}
	
	/**
	 * Track user privileges.
	 * @param Zend_Controller_Request_Abstract $request
	 * @return void
	 */
	public function	preDispatch(Zend_Controller_Request_Abstract $request)
	{
		
		$module=$request->module;
		$controller=$request->controller;
		$action=$request->action;
        $request->setModuleName($module);
		$request->setControllerName($controller);
		$request->setActionName($action);
	}
} 